<template>
    <div class="wrap">
       <!-- <Header :navTitle="title" :showBack="showBack"></Header> -->
        <mt-loadmore  :bottom-method="loadBottom" :bottom-all-loaded="allLoaded" ref="loadmore" v-if="doctorList.length" bottomPullText=" " bottomDropText=" " bottomLoadingText=" ">
            <ul class='doctor-list'>
                <li class='doctor-item flex' @click='goDetail(item.doctorid)' v-for="(item,index) in doctorList" :key="index">
                    <div class='item-left'>
                        <img :src='item.avatar' class='imgActive' ></img>
                    </div>
                    <div class='item-right column'>
                        <div class='name-wrap flex'>
                            <p class='name'>{{item.doctorname}}  {{item.descr}}</p>
                            <div class='status flex'>
                                <div class="online flex" :class="{'active':item.online_status == 1}">{{item.online_status == 1?'在线':'离线'}}</div>
                                <div class='time' v-if="item.visitnumber>0">就诊过{{item.visitnumber}}次</div>
                            </div>
                        </div>
                        <div class='intro overhidden'>{{item.orgname}}</div>
                        <div class='skill flex'>
                            <span class='skill-item overhidden' v-for="(items,key) in item.doctor_illness" :key="key">{{items}}</span>
                        </div>
                        <div class='price-wrap flex'>
                            <span class='price'>￥{{item.img_inquiry_fee}}元/次</span>
                            <div class="look flex" v-if="clinicid" @click.stop="goRegistration(item.doctorid)">预约挂号</div>
                            <span class='num'>{{item.commentnumber || 0}}条评价</span>
                            <div class='look flex'>查看评价</div>
                        </div>
                    </div>
                </li>
                <li class="page-loading flex" v-if="pageLoading">
                    <img src='../assets/load.gif'></img>
                    <span>加载中</span>
                </li>
            </ul>
        </mt-loadmore>
        <div class='no-data flex' v-else>
            <img src='../assets/no-data.png'></img>
            <p>暂无医生信息</p>
        </div>
        <!-- 加载中 -->
        <div class='loading column' v-if="showLoading">
            <img src='../assets/load.gif'></img>
            <p>拼命加载中...</p>
        </div>
    </div>
</template>

<script>
import Bar from "./Bar";
import Header from "./header";
import { searchdoctor } from "./../api/index";
import { Loadmore } from 'mint-ui';
import { registrationUrl } from "./../config/index";
import axios from "axios";
export default {
    data(){
        return{
            title: "名医列表",
            showBack: true,
            flag: true,//防止多次跳转的变量
            search:'',//搜索词
            clinicid:'',//门诊id
            status:'',
            page:0,
            pagesize:10,
            doctorList:[],//医生数组
            showLoading:true,//页面初加载中
            allLoaded:false,
            pageLoading:false,//是否显示加载中
        }
    },
    components: {
        Bar,
        Header
    },
    mounted(){
        console.log(this.$route.params)
        if(this.$route.params.clinicid){
            this.clinicid = this.$route.params.clinicid
            this.status = this.$route.params.registration
        }
        if(this.$route.params.keyword){
            this.search = this.$route.params.keyword
        }else{
            this.search = ''
        }
        this.getDoctorListTap()
    },
    methods:{
        //获取医生列表
        getDoctorListTap(){
            let mstr = sessionStorage.getItem('mstr')
            searchdoctor(mstr,this.search,this.page,this.pagesize).then((res)=>{
                if(res.data.status === 1){
                    this.doctorList = this.doctorList.concat(res.data.data)
                    this.page = this.page + this.pagesize
                }else{
                    this.allLoaded = true;
                    if(this.$refs.loadmore){
                        this.$refs.loadmore.onBottomLoaded();
                    }
                }
                this.pageLoading = false;
                this.showLoading = false
            })
        },
        //加载更多
        loadBottom(){
            this.pageLoading = true;
            this.getDoctorListTap()
        },
        //去门诊挂号
        goRegistration(id){
            axios.post(registrationUrl,{
                    doctorid:id,
                    orgid:this.clinicid
            }).then((res)=>{
                if(res.data.status === 1){
                    console.log(res.data)
                    location.href = res.data.data.URL
                }
            })
        },
        //去医生详情
        goDetail(id){
            this.$router.push({
                name:`doctorDetail`,
                params:{
                    id:id,
                    clinicid:this.clinicid,
                    status:this.status
                }
            })
        }
    },
    props: {

    }
};
</script>

<style lang="scss" scoped>
@import "../base/css/_base.scss";
/* pages/doctorList/doctorList.wxss */
.doctor-list .doctor-item{
    padding: torem(25px) torem(30px);
    border-bottom: 1px solid #d9d9d9;
    background: #fff;
}
.doctor-item .item-left{
    margin-right: torem(20px);
}
.doctor-item .item-left img{
    width: torem(96px);
    height: torem(96px);
    border-radius: 50%;
    border:torem(4px) solid #F1BE74;

}
.doctor-item .item-right{
    flex: 1;
}
.item-right .name-wrap{
    justify-content: space-between;
    align-items: center;
}
.item-right .name-wrap .name{
    color: #333333;
    font-size: torem(30px);
    font-weight: bold;
}
.item-right .status .online{
    width: torem(60px);
	height: torem(38px);
	background-color: #999;
	border-radius: torem(6px);
    color: #fff;
    font-size: torem(20px);   
    justify-content: center;
    align-items: center;
}
.item-right .status .online.active{
    background-color: #db5033;
}
.item-right .status .time{
    height: torem(38px);
	border-radius: torem(6px);
	border: solid 1px #da9384;
    align-items: center;
    padding: 0 torem(7px);
    color: #db5033;
    font-size: torem(20px);
    margin-left: torem(20px);
}
.item-right .intro{
    color: #999999;
    font-size: torem(22px);
    margin:torem(10px) 0 torem(10px) 0;
    max-width: torem(500px);
}
.item-right .skill{
    flex-wrap: wrap;
}
.item-right .skill .skill-item{
    color: #333333;
    font-size: torem(24px);
    border-radius: torem(6px);
	border: solid 1px #b2b2b2;
    padding: torem(8px) torem(14px);
    margin-right: torem(20px);
    margin-bottom: torem(15px);
    max-width: torem(250px);
}
.item-right .price-wrap{
    align-items: center;
}
.price-wrap .price{
    color: #db5033;
    font-size: torem(24px);
    flex: 1;
}
.price-wrap .num{
    color: #999999;
    font-size: torem(22px);
    margin-left: torem(30px);
}
.price-wrap .look{
    width: torem(120px);
	height: torem(40px);
	border-radius: torem(6px);
	border: solid 1px #da9384;
    color: #db5033;
    font-size: torem(20px);
    align-items: center;
    justify-content: center;
    margin-left: torem(20px);
}
.page-loading{
    font-size: torem(24px);
    align-items: center;
    justify-content: center;
    padding: torem(30px) 0;
    img{
        width: torem(32px);
        height: torem(32px);
        margin-right: torem(20px);
    }
}

</style>